package com.imonsoft.sqm.dao.basedata;

import com.imonsoft.common.httpModel.DataGrid;
import com.imonsoft.common.httpModel.Pager;
import com.imonsoft.sqm.pojo.basedata.Dictionary;
import com.imonsoft.sqm.pojo.basedata.DictionaryExample;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@SuppressWarnings("deprecation")
@Repository("dictionaryDAO")
public class DictionaryDAOImpl extends SqlMapClientDaoSupport implements DictionaryDAO {

    /**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public DictionaryDAOImpl() {
		super();
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int countDictionaryByExample(DictionaryExample example) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject(
				"tm_dictionary.ibatorgenerated_countByExample", example);
		return count;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int deleteDictionaryByExample(DictionaryExample example) {
		int rows = getSqlMapClientTemplate().delete(
				"tm_dictionary.ibatorgenerated_deleteByExample", example);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int deleteDictionaryByPrimaryKey(Long id) {
		Dictionary key = new Dictionary();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete(
				"tm_dictionary.ibatorgenerated_deleteByPrimaryKey", key);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public Long insertDictionary(Dictionary record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"tm_dictionary.ibatorgenerated_insert", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public Long insertDictionarySelective(Dictionary record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"tm_dictionary.ibatorgenerated_insertSelective", record);
		return (Long) newKey;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	@SuppressWarnings("unchecked")
	public List<Dictionary> selectDictionaryByExample(DictionaryExample example) {
		List<Dictionary> list = getSqlMapClientTemplate().queryForList(
				"tm_dictionary.ibatorgenerated_selectByExample", example);
		return list;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public Dictionary selectDictionaryByPrimaryKey(Long id) {
		Dictionary key = new Dictionary();
		key.setId(id);
		Dictionary record = (Dictionary) getSqlMapClientTemplate()
				.queryForObject(
						"tm_dictionary.ibatorgenerated_selectByPrimaryKey", key);
		return record;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int updateDictionaryByExampleSelective(Dictionary record,
			DictionaryExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate()
				.update("tm_dictionary.ibatorgenerated_updateByExampleSelective",
						parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int updateDictionaryByExample(Dictionary record,
			DictionaryExample example) {
		UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
		int rows = getSqlMapClientTemplate().update(
				"tm_dictionary.ibatorgenerated_updateByExample", parms);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int updateDictionaryByPrimaryKeySelective(Dictionary record) {
		int rows = getSqlMapClientTemplate().update(
				"tm_dictionary.ibatorgenerated_updateByPrimaryKeySelective",
				record);
		return rows;
	}

	/**
	 * This method was generated by Apache iBATIS ibator. This method corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	public int updateDictionaryByPrimaryKey(Dictionary record) {
		int rows = getSqlMapClientTemplate().update(
				"tm_dictionary.ibatorgenerated_updateByPrimaryKey", record);
		return rows;
	}

	/**
	 * This class was generated by Apache iBATIS ibator. This class corresponds to the database table tm_dictionary
	 * @ibatorgenerated  Mon May 27 16:34:17 CST 2013
	 */
	private static class UpdateByExampleParms extends DictionaryExample {
		private Object record;

		public UpdateByExampleParms(Object record, DictionaryExample example) {
			super(example);
			this.record = record;
		}

		@SuppressWarnings("unused")
		public Object getRecord() {
			return record;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public DataGrid<Dictionary> getDataGrid(DictionaryExample example, Pager pager) {
		if (example == null) {
			example = new DictionaryExample();
		}
		int total = countDictionaryByExample(example);
		List<Dictionary> rows = getSqlMapClientTemplate().queryForList("tm_dictionary.ibatorgenerated_selectByExample", example, pager.getSkipResults(), pager.getRows());
		DataGrid<Dictionary> dataGrid = new DataGrid<Dictionary>(total, rows);
		return dataGrid;
	}

	@SuppressWarnings("unchecked")
	@Override
	public DataGrid<Dictionary> getDictionaryType(Pager pager) {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("tm_dictionary.select_count_dictionary_type", pager.getSkipResults(), pager.getRows());
		List<Dictionary> list = getSqlMapClientTemplate().queryForList("tm_dictionary.select_dictionary_type", pager.getSkipResults(), pager.getRows());
		DataGrid<Dictionary> dataGrid = new DataGrid<Dictionary>(count, list);
		return dataGrid;
	}
}